<template>
  <base-breadcrumb v-loading="loading" :breadcrumb="!isAudit">
    <div class="page-detail">
      <a-card>
        <title-name title="风险信息" />
        <a-descriptions>
          <a-descriptions-item label="所属单位">
            {{ form1.branchCompany + '/' +form1.project}}
          </a-descriptions-item>
          <!-- <a-descriptions-item label="所属分公司">
            {{ form1.branchCompany }}
          </a-descriptions-item>
          <a-descriptions-item label="项目名称">
            {{ form1.project }}
          </a-descriptions-item> -->
          <a-descriptions-item label="是否风险要素库风险">
            {{ form1.haveRiskFactors ? '是' : '否' }}
          </a-descriptions-item>
        </a-descriptions>
        <a-descriptions>
          <a-descriptions-item label="风险名称">
            {{ form1.riskName }}
          </a-descriptions-item>
          <a-descriptions-item label="风险描述">
            {{ form1.riskContent }}
          </a-descriptions-item>
        </a-descriptions>
        <a-descriptions layout="vertical">
          <a-descriptions-item label="风险级别">
            <a-radio-group
              v-model="form1.riskLevel"
              style="width: 100%"
            >
              <div :style="radioStyle">
                <a-radio
                  :value="1"
                  :disabled="form1.riskLevel !== 1"
                >
                  一般风险
                </a-radio>
                {{ form1.generalRisk }}
              </div>
              <div :style="radioStyle">
                <a-radio
                  :value="2"
                  :disabled="form1.riskLevel !== 2"
                >
                  较大风险
                </a-radio>
                {{ form1.greaterRisk }}
              </div>
              <div :style="radioStyle">
                <a-radio
                  :value="3"
                  :disabled="form1.riskLevel !== 3"
                >
                  重大风险
                </a-radio>
                {{ form1.majorRrisk }}
              </div>
            </a-radio-group>
          </a-descriptions-item>
        </a-descriptions>
        <a-descriptions>
          <a-descriptions-item label="责任部门">
            {{ form1.orgName }}
          </a-descriptions-item>
        </a-descriptions>
        <!-- <a-descriptions>
            <a-descriptions-item label="责任人">{{ form1.personLiableName }}</a-descriptions-item>
            <a-descriptions-item label="处理时限">{{ form1.processingTime | dateFormat('D') }}</a-descriptions-item>
            </a-descriptions> -->
        <a-descriptions>
          <a-descriptions-item label="创建人">
            {{ form1.creatorName }}
          </a-descriptions-item>
          <a-descriptions-item label="创建时间">
            {{ form1.createTime || '无' }}
          </a-descriptions-item>
        </a-descriptions>
      </a-card>
      <!-- 工作要求 -->
      <a-card>
        <title-name title="工作要求" />
        <a-table
          bordered
          :data-source="form1.workContent ? [form1] : []"
          row-key="id"
          :columns="columnsWork"
          :pagination="false"
        />
      </a-card>

      <!-- 法律风险 -->
      <a-card>
        <title-name title="法律风险" />
        <a-table
          bordered
          :data-source="form1.riskLawBusVO ? [form1.riskLawBusVO] : []"
          row-key="id"
          :columns="columnsLaw"
          :pagination="false"
        />
      </a-card>

      <!-- 批注意见 -->
      <comments
        v-if="form1.id"
        :id="form1.id"
        :is-detail="true"
      />

      <!-- 风险处理 -->
      <risk
        v-if="form1.id"
        :id="form1.id"
        :is-detail="true"
      />

      <!-- 风险销项 -->
      <a-card>
        <title-name title="风险销项" />
        <a-descriptions>
          <a-descriptions-item label="证明附件">
            <a
              v-if="form1.riskSalesBusVO.fileInfoVO.fileName"
              :href="$fileUrl(form1.riskSalesBusVO.fileInfoVO)"
            >
              {{ form1.riskSalesBusVO.fileInfoVO.fileName }}</a>
            <div v-else>
              无
            </div>
          </a-descriptions-item>
        </a-descriptions>
        <a-descriptions>
          <a-descriptions-item label="销项说明">
            {{ form1.riskSalesBusVO.salesContent || '无' }}
          </a-descriptions-item>
        </a-descriptions>
        <a-descriptions>
          <a-descriptions-item label="销项人">
            {{ form1.riskSalesBusVO.creatorName || '无' }}
          </a-descriptions-item>
          <a-descriptions-item label="销项时间">
            <div>
              {{ form1.riskSalesBusVO.modifiedTime || '无' }}
            </div>
          </a-descriptions-item>
        </a-descriptions>
      </a-card>

      <!-- 相关附件 -->
      <a-card v-if="form1.id">
        <title-name title="相关附件" />
        <u-table
          :is-show="false"
          business-code="LCM10"
          :list-url="findFileList"
          :upload-list="addFile"
          :delete-url="deleteFile"
          :business-id="form1.id"
        />
      </a-card>

      <div v-if="!isConsultation" class="tar page-btn-right-top">
        <a-button
          v-checkVisibleInDetail
          @click="$close"
        >
          关闭
        </a-button>
      </div>
    </div>
  </base-breadcrumb>
</template>

<script>
import riskListApi from '@/api/legal/risk/list'
import comments from '@/views/Legal/risk/list/components/comments'
import risk from '@/views/Legal/risk/list/components/risk'

export default {
  name: 'a' + Date.now(),
  components: {
    comments,
    risk
  },
  props: {
    // 是否作为审批详情
    isAudit: {
      type: Boolean,
      default: false
    },
    // 是否作为意见征询
    isConsultation: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      radioStyle: {
        display: 'flex',
        'align-items': 'center',
        'margin-bottom': '10px'
      },
      loading: false,
      form1: {
        riskSalesBusVO: { fileInfoVO: {} }
      },
      columnsLaw: [
        {
          title: '序号',
          dataIndex: 'index',
          width: 70,
          customRender() {
            return arguments[2] + 1
          }
        },
        {
          title: '法律风险',
          dataIndex: 'content',
          width: '50%'
        },
        {
          title: '提交人',
          dataIndex: 'creatorName',
          width: 220
        },
        {
          title: '提交时间',
          dataIndex: 'createTime',
          width: 120
        },
        {
          title: '状态',
          dataIndex: 'auditStatusStr',
          width: 220
        }
      ], // 法律风险表头
      columnsWork: [
        {
          title: '序号',
          dataIndex: 'index',
          width: 70,
          customRender() {
            return arguments[2] + 1
          }
        },
        {
          title: '工作要求',
          dataIndex: 'workContent',
          width: '50%'
        },
        {
          title: '责任人',
          dataIndex: 'personLiableName',
          width: 220
        },
        {
          title: '完成时限',
          dataIndex: 'processingTime',
          width: 120
        },
        {
          title: '抄送人',
          dataIndex: 'personCCName',
          width: '20%'
        }
      ], // 工作要求表头
      addFile: riskListApi.addFile(),
      deleteFile: riskListApi.deleteFile(),
      findFileList: riskListApi.findFileList()
    }
  },
  created() {
    this.getBaseInfo()
  },
  methods: {
    async getBaseInfo() {
      this.loading = true
      let res
      if (this.$route.query.businessId) {
        if (this.$route.query.businessType === '1115') {
          res = await riskListApi.findBaseByCommentsId({}, { id: this.$route.query.businessId })
        } else {
          res = await riskListApi.findByBusinessId({}, { id: this.$route.query.businessId })
        }
      } else {
        res = await riskListApi.findListByMainId({}, { id: this.$route.query.id })
      }
      if (res.code === this.SUCCESS_CODE) {
        this.form1 = res.data
        if (!this.form1.riskSalesBusVO) {
          this.form1.riskSalesBusVO = { fileInfoVO: {} }
        }
      }
      this.loading = false
    }
  }
}
</script>

<style scoped>
</style>
